<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/admin/common/common.jsp" %>
<%@ include file="/admin/common/layui_head.html" %>
<head>
    <meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8"/>
    <script src="/js/jquery-3.4.1.min.js"></script>
    <script src="/layuiadmin/layui/layui.all.js"></script>
    <script src="/js/jquery-form.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <form class="layui-form layui-card-header layuiadmin-card-header-auto" id="layuiForm" onsubmit="return false;">
<%--                    <div class="layui-inline">--%>
<%--                        &nbsp;&nbsp;企业名称&nbsp;--%>
<%--                        <div class="layui-inline" style="width: 200px">--%>
<%--                            <ht:heroenterpriseselect id="enterprise_No_Head" name="enterprise_No" />--%>
<%--                        </div>--%>
<%--                    </div>--%>
                    <div class="layui-inline">
                        &nbsp;&nbsp;企业用户&nbsp;
                        <div class="layui-inline" style="width: 200px">
                            <ht:herocustomdataselect dataSourceType="allEnterpriseUsers" name="enterprise_User_Id" />
                        </div>
                    </div>

                    <div class="layui-inline">
                        &nbsp;&nbsp;通道&nbsp;
                        <div class="layui-inline" style="width: 200px">
                            <ht:herocustomdataselect dataSourceType="allChannels" name="channel_No" />
                        </div>
                    </div>


                    <div class="layui-inline">
                        <%--                        &nbsp;&nbsp;分组&nbsp;--%>
                        <div class="layui-inline" style="width: 100%">
                            <input type="text" name="groupStr" id="groupStr" value="Channel_No" hidden/>
                            <input type="text" id="groupStrNoChecked" value="enterprise_No,enterprise_User_Id" hidden/>
<%--                            <input type="checkbox" lay-filter="group" value="Enterprise_No" lay-skin="primary" title="企业">--%>
                            <input type="checkbox" lay-filter="group" value="Enterprise_User_Id" lay-skin="primary" title="用户">
                            <input type="checkbox" lay-filter="group" value="Channel_No" lay-skin="primary" title="通道" checked="">
                        </div>
                    </div>
                    <div class="layui-inline">
                        &nbsp;&nbsp;提交时间&nbsp;
                        <div class="layui-inline" style="width: 200px">
                            <input type="text" class="layui-input" id="min_Submit_Date" name="min_Submit_Date_Str">
                        </div>-
                        <div class="layui-inline" style="width: 200px">
                            <input type="text" class="layui-input" id="max_Submit_Date" name="max_Submit_Date_Str">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm" type="submit" lay-submit="" lay-filter="reload">搜索
                        </button>
                    </div>
                </form>
                <div class="layui-form layui-border-box layui-table-view">
                    <div class="layui-card-body">
                        <table class="layui-hide" id="list_table" lay-filter="list_table"></table>
                        <script type="text/html" id="table-toolbar">
                            <div class="layui-btn-container">
                                <%@include file="/admin/common/button_action_list.jsp" %>
                            </div>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    var $;
    var interval = 1;
    layui.extend({tableExt: '/layuiadmin/extends/tableExt'}).use(['tableExt', 'laydate'], function () {
        var table = layui.tableExt;
        $ = layui.$;
        table.render({
            url: '/admin/statistic_unknownStatisticList',
            where: {
                'groupStr': $("#groupStr").val(),
                'min_Submit_Date_Str': $("#min_Submit_Date").val()==''?new Date(new Date()-1000*60*30):$("#min_Submit_Date").val(),
                'max_Submit_Date_Str': $("#max_Submit_Date").val()==''?getFormatDateBefore(1):$("#max_Submit_Date").val(),
            },
            // totalRow: true,
            cols: [[
                // {checkbox: true, totalRowText: '合计', width: 60},
                // {field: 'enterprise_No', title: '企业名称',templet:function (d) {
                //         return !d.enterprise_No_ext?'---':handleData(d.enterprise_No_ext.name);
                //     }},
                {field: 'enterprise_User_Id', title: '企业名称 / 企业用户',minWidth: 300, templet:function (d) {
                        var str = !d.enterprise_No_ext?'---':handleData(d.enterprise_No_ext.name)+' / ';
                        str += !d.enterprise_User_Id_ext ? '---' : handleData(d.enterprise_User_Id_ext.real_Name)
                            +"("+handleData(d.enterprise_User_Id_ext.user_Name)+")";
                        return str;
                    }},
                {field: 'channel_No', title: '发送通道',minWidth: 200,templet:function (d) {
                        return !d.channel_No_ext?'---':handleData(d.channel_No_ext.name);
                    }},
                // {field: 'submit_Total', title: '提交条数', width: 120, totalRow: true},
                {field: 'submit_Success_Total', title: '提交成功', width: 120},
                {field: 'submit_Faild_Total', title: '提交失败', width: 120},
                // {field: 'sort_Faild_Total', title: '分拣失败', width: 120, totalRow: true},
                {field: 'send_Success_Total', title: '发送成功', width: 120},
                {field: 'send_Faild_Total', title: '发送失败', width: 120},
                { title: '发送未知', width: 120, templet:function (d) {
                        var send_Unknown_Sms_Total = d.submit_Success_Total-(d.send_Success_Total+d.send_Faild_Total);
                        return send_Unknown_Sms_Total<0?0:send_Unknown_Sms_Total;
                    }},
                { title: '成功率',templet:function (d) {
                        if(!d.submit_Success_Total)return '---';
                        var point = d.send_Success_Total/d.submit_Success_Total;
                        return Number(point*100).toFixed(1)+"%";
                    },width: 100},
                { title: '失败率',templet:function (d) {
                        if(!d.submit_Success_Total)return '---';
                        var point = d.send_Faild_Total/d.submit_Success_Total;
                        return Number(point*100).toFixed(1)+"%";
                    },width: 100},
                { title: '未知率',templet:function (d) {
                        if(!d.submit_Success_Total)return '---';
                        var point = 1-d.send_Success_Total/d.submit_Success_Total-d.send_Faild_Total/d.submit_Success_Total;
                        return Number(point*100).toFixed(1)+"%";
                    },width: 100},

            ]],page: false
            ,done: function(res, curr, count){
                var str = $("#groupStrNoChecked").val();
                var notChecked = str.split(',');
                for (var value of notChecked) {
                    $("[data-field="+value+"]").css('display','none');
                }
            }
        });
    });


    layui.use(['form', 'laydate'], function () {
        var $ = layui.$
            , form = layui.form;
        //监听复选框
        form.on('checkbox(group)', function (data) {
            var groupStr = $("input[lay-filter='group']:checked").map(function () {
                return $(this).val();
            }).get().join(',');
            var Delimiter = groupStr?',':'';
            $("#groupStr").val(groupStr);
            var groupStrNoChecked = $("input[lay-filter='group']:not(:checked)").map(function () {
                var str = $(this).val();
                return str.replace(str[0],str[0].toLowerCase());
            }).get().join(',');
            $("#groupStrNoChecked").val(groupStrNoChecked);
        });
        var laydate = layui.laydate;
        var today = new Date();
        laydate.render({     //创建时间选择框
            elem: '#min_Submit_Date' //指定元素
            ,type:'datetime'
            ,trigger : 'click'
            ,value: getFormatDateBeforeMinutes(30)
            ,min: getFormatDateBeforeMinutes(60)
        });
        laydate.render({     //创建时间选择框
            elem: '#max_Submit_Date' //指定元素
            ,type:'datetime'
            ,trigger : 'click'
            ,value: new Date()
            ,min: getFormatDateBeforeMinutes(60)
        });
    });

    layui.use(['form'], function () {
        var form = layui.form
        form.render();
    });

    //获取form表单数据
    function getFormData() {
        return $("#layuiForm").serialize();
    }
</script>